<?php

include_once('configure.php');

class FileLog
{

  /**
   * The open file handle.
   *
   * @access private
   */

  var $theFileName=FILE_LOG;
  var $m_handle;


  	function FileLog()
	{
	    if (file_exists($this->theFileName))
	    {
	      $this->m_handle = @fopen($this->theFileName, 'a') ;
	    }
	    else
	    {
	      $this->m_handle = @fopen($this->theFileName, 'w') ;
	    }	
	    if ($this->m_handle == FALSE)
	    {
		trigger_error('Failed to open log file: ' . $this->theFileName . '\n' .
		  'Current working directory: ' . getcwd(), E_USER_WARNING) ;
	    } 
	}

	function close()
	{
		if ($this->m_handle != FALSE)
		{
			fclose($this->m_handle) ;
		}
	}

  
	function writeLog($val)
	{
		$theData=date('[d-m-Y H:i:s]')." ".$val."\n";
		echo "$theData";
		if ($this->m_handle != FALSE)
		{
			//return fwrite($this->m_handle, $theData) ;
			error_log('['.$theData.'] INFO: '.$message.PHP_EOL, 3, $this->theFileName);
		}
	}
}
?>